home *** CD-ROM | disk | FTP | other *** search
- ##############################################################################
- # This script is a small host. #
- # It connects to incoming calls and allows to perform certain functions #
- # according to the level of authorisation. #
- # Ideas of Mike Nowostawsky's Script HOSTZOC2 are used. #
- # #
- # 'nnnnnnnn' in the following text stands for the name of the phone book #
- # entry calling this script. If the script was called directly then #
- # 'nnnnnnnn' is substituted by 'KF_HOST' (held in variable SCRIPTNAME). #
- # Unless using HPSF, nnnnnnnn should not exceed 8 characters. #
- # #
- # USED FILES AND THEIR NAMES #
- # -------------------------- #
- # - Script file: #
- # SCRIPT\KF_HOST #
- # - Password files: #
- # SCRIPT\nnnnnnnn.PSW #
- # File SCRIPT\KF_HOSTX.PSW is delivered with this script as a start. #
- # - Option files: #
- # OPTIONS\nnnnnnnn.STD is in use while waiting for incoming calls. #
- # OPTIONS\nnnnnnnn.CON is in use while being connected to remote. #
- # Files OPTIONS\KF_HOSTX.STD and OPTIONS\KF_HOSTX.CON are delivered with #
- # this script as a start. #
- # - Log file: #
- # The name of the log file is taken from the phone book entry. #
- # If the script was called directly or was not specified in the phone #
- # entry, then the name of the log file is defaulted to 'KF_HOST.LOG'. #
- # #
- # FUNCTIONS AND LEVEL OF AUTHORIZATION: #
- # ------------------------------------- #
- # There are two levels of authorisation. #
- # Normal level of authorisation allows following functions: #
- # - Download of files from the host directory (default "D:\ZocD\HostDir\"). #
- # - Upload to host \ZocD\Download #
- # - List of files in current directory in host. #
- # - Send message to host. #
- # Extended level of authorisation allows following additional functions: #
- # - Changing of the host directory #
- # - List of dirs in current directory in host. #
- # Wether extended functions are allowed or not is determined by the password.#
- # Passwords are held in ASCII file SCRIPT\nnnnnnnn.PSW. #
- # One password is represented by one line. The format of passwords is as #
- # follows: #
- # e password #
- # ┬ ───┬──── #
- # │ └────── Password. Passwords are case sensitive. #
- # └─────────── 1 if Password authorizes for extended functions (else 0) #
- # The delivered password file SCRIPT\KF_HOSTX.PSW has the following two #
- # lines. #
- # 0 KF_HOST #
- # 1 KF_HOSTEXT #
- # #
- # COMMANDS WHICH CAN BE PERFORMED BY THIS SCRIPT: #
- # ----------------------------------------------- #
- # CD alias C = Change Dirctory #
- # DIR alias D = File-List of Current Directory #
- # DIRD alias DD = Dir-List of Current Directory #
- # UL = UpLoad (Remote: ZModem UpLoad, Host ZModem DownLoad) #
- # DL = DownLoad (Remote: ZModem DownLoad, Host ZModem UpLoad) #
- # Wild cards in filespec are allowed. #
- # >mmmmmmmm = Send Message mmmmm to Host #
- # >>mmmmmmmm = Ring Bell at Host and Send Message mmmmm to Host #
- # Exit alias E = Hangup #
- # Help alias ? = Help #
- # #
- # DEAFULT VARIABLES #
- # ----------------- #
- # See #
- # ###################......######## #
- # # Set defaults # #
- # #################......########## #
- # in this script. #
- # #
- ##############################################################################
-
- ##############################################################################
- # #
- # SETUP #
- # #
- # Two option files are used by this script. The names of this option files #
- # are held in the variables HOSTWAIT and HOSTECHO. #
- # HOSTWAIT is active while waiting for an incoming call #
- # HOSTCONN is active while being connected with the caller #
- # HOSTWAIT is defaulted to OPTIONS\Standard #
- # HOSTCONN is defaulted to OPTIONS\HostConn #
- # #
- # The file OPTIONS\HostConn should be set as follows: #
- # - Load option file Standard #
- # - Make sure the following items are set: #
- # - SERIAL: RTS/CTS handshake (*ON* - check mark) #
- # - TERMINAL: Incoming CR to CR/LF (*ON* - check mark) #
- # Local echo (half duplex) (*ON* - check mark) #
- # Send echo (host mode) (*ON* - check mark) #
- # - TRANSFER: ASCII Upload: CR -> CR/LF (*ON* - check mark) #
- # char delay = 0 (faster ASCII up- and download #
- # ZModem Options: Autotransfer. #
- # File Exists: Overwrite. #
- # Warning: Existing files in Host \ZocD\DOWNLOAD will #
- # be overwritten on file transfer from remote. #
- # - MODEM: Empty the Initialisation string and turn off the two #
- # associated checkmarks #
- # #
- # - Save the options as HostConn #
- # #
- ##############################################################################
- :Start
- ###########################################################################
- # Set defaults #
- ###########################################################################
- SetA SCRIPTNAME "KF_HOST" ;#the name of this script
- SetA PHONEBOOKORG "%lastline%" |BOX= ;#extract phonebook entry
- SetA PHONEBOOKNAME "%PHONEBOOKORG%"
- SetA LOGFILE "%lastline%" |LOG= ;#extract name of logfile
- ################# Set defaults to %SCRIPTNAME% if needed ##################
- CompA "%PHONEBOOKORG%" with ""
- IfEqu SetA PHONEBOOKNAME "%SCRIPTNAME%"
- CompA "%LOGFILE%" with ""
- IfEqu SetA LOGFILE "%SCRIPTNAME%.LOG"
- ######################## Set names of option files ########################
- SetA HOSTWAIT "OPTIONS\%PHONEBOOKNAME%.Std"
- SetA HOSTCONN "OPTIONS\%PHONEBOOKNAME%.Con"
- ########################## Set names of log file ##########################
- Seta PASSWORDFILE "Script\%PHONEBOOKNAME%.PSW" ;#name of file with passwords
- SetA CURDIR "D:\ZocD\HostDir\" ;#default host directory for sending
-
- ################ NUMOFRINGS, WAITTIME, TEMPFILE, VERSION. #################
- SetA NUMOFRINGS "3"
- SetN WAITTIME "10"
- SetA TEMPFILE "KF_HOST.TMP"
- SetA VERSION "1.10"
-
- ###########################################################################
- # Start logging and write start messages #
- ###########################################################################
- LogName "%LOGFILE%"
- Logging 1
- Writeln "*************************************************************************"
- Writeln "Script >%SCRIPTNAME%< Version %VERSION% started."
- Writeln "Following items are in use:"
- Writeln "PhonebookEntry: %PHONEBOOKORG%"
- Writeln "PasswordFile: %PASSWORDFILE%"
- Writeln "OptionFiles: OPTIONS\%PHONEBOOKNAME%.Std and OPTIONS\%PHONEBOOKNAME%.Con"
- Writeln "LogFile: %LOGFILE%"
- Writeln "Number of rings: %NUMOFRINGS%"
- Writeln "*************************************************************************"
- ###########################################################################
- # Set case sensitive compare. #
- ###########################################################################
- Exact 1
- ###########################################################################
- # This is the Main loop #
- ###########################################################################
- :Main
- Timeout %WAITTIME%
- ########################################################################
- # Prepare for Wait #
- ########################################################################
- Call WaitSetup
- ########################################################################
- # Wait for connect #
- ########################################################################
- Writeln "******* Waiting for call...."
- :ConWait
- Wait "CONNECT"
- IfBrk Goto ConWait
- Call CheckModem
- CompN %modem% with 1
- IfnEqu Goto ConWait
- Wait "^M"
- IfBrk Goto Main ;#should not occur
- Call CheckModem
- CompN %modem% with 0
- IfnEqu Goto Main ;#should not occur
- :ConWaitEnd
- ########################################################################
- # Send 'Hit Enter... message and wait for Enter. #
- # This is to drain evtl. garbage characters. #
- ########################################################################
- delay 3 ;#delay to give remote a chance to look
- send "^[[2J" ;#clear screen on remote/caller side
- send "^MHit Enter key to start host..."
- :ConWaitEnter
- wait "^M" ;#wait for Enter to clear garbage characters
- IfBrk Goto ConWaitEnter
- Call CheckModem ;#check for drop conditions
- CompN %modem% with 1
- IfHigh Goto Main ;#unexpected, da capo
- :ConWaitEnterEnd
-
- ########################################################################
- # Send welcome message and ask for password #
- ########################################################################
- Send "^M Welcome !! Enter Password: "
- :ConWaitPasswWait
- WaitLine
- IfBrk Goto ConWaitPasswWait
- Call CheckModem ;#check for drop conditions
- CompN %modem% with 1
- IfHigh Goto Main ;#error, da capo
- :ConWaitPasswWaitEnd
- ########################################################################
- # Check password #
- ########################################################################
- Call CheckPassWord
- CompN %passwordok% with 1
- IfEqu Goto ConWaitPasswCheckEnd ;#password ok
- #####################################################################
- # Wrong password #
- #####################################################################
- Send "^M^J>>>>>> Sorry, not authorized... Bye! <<<<<<^M^J"
- Goto Main
- :ConWaitPasswCheckEnd
- Send "Password ok^M^J"
- Writeln "******* Loading option file %HOSTCONN% for Connect..."
- LoadOpts "%HOSTCONN%"
- Delay 1
- ########################################################################
- # Process orders from remote. Stay in routine Connect till break. #
- ########################################################################
- Call Connect
- Goto Main ;#all over again
- :MainEnd
- exit
-
- ##############################################################################
- # SUBROUTINES #
- ##############################################################################
-
-
- ##############################################################################
- # WaitSetup #
- ##############################################################################
- :WaitSetup
- Writeln "******* Loading option file %HOSTWAIT% for Wait..."
- LoadOpts "%HOSTWAIT%"
- Delay 1
- HangUp
- Delay 1
- LoadOpts "%HOSTWAIT%"
- Delay 1
- ###########################################################################
- # Set up for Auto Answer #
- ###########################################################################
- Send "ATS0=%NUMOFRINGS%^M"
- Delay 1
- Compa "%lastline%" with "OK"
- IfEqu Goto WaitSetupEnd
- SetA desaster "Failure on ATS0. %lastline%"
- Goto Desaster
- :WaitSetupEnd
- return
-
- ##############################################################################
- # CheckDirPresent #
- # Checks wether Dir in filename exist. #
- # filenamesave gets the original filename #
- # If exists: filename is left as it is. Else filename is set to "" #
- ##############################################################################
- :CheckDirPresent
- ###########################################################################
- # Evtl. add trailing \ #
- ###########################################################################
- SetA backsl "%filename%" -1 1
- CompA "%backsl%" with "\"
- IfnEqu SetA filename "%filename%\"
- SetA filenamesave "%filename%"
- Shell "dir /ad %filename%*>%TEMPFILE%" ;#create list of dir names
- OpenFile "%TEMPFILE%" "r"
- ###########################################################################
- # Check wether '<DIR>' appears in one of the lines #
- ###########################################################################
- :CheckDirPresentLoop
- GetFile
- CompA "%lastline%" with "##" ;#Check for end
- IfnIn Goto CheckDirPresentLoop10
- #####################################################################
- # Directory does not exist. Clear file name #
- #####################################################################
- SetA filename ""
- Goto CheckDirPresentLoopEnd
- :CheckDirPresentLoop10
- CompA "%lastline%" with "<DIR>"
- IfnIn Goto CheckDirPresentLoop
- :CheckDirPresentLoopEnd
- CloseFile
- Shell "del %TEMPFILE%"
- return
-
- ##############################################################################
- # CheckModem #
- # Num Variable modem is set to the following values according to the #
- # contents of the system variable lastline: #
- # #
- # 2 "NO CARRIER", "x...x+++x...x", "HANGUP" or "HANG UP", #
- # "BUSY", "NOANSWER" or "NO ANSWER", #
- # "NODIALTONE" or "NO DIALTONE", "SYSTEM SUSPENDED", "ERROR" #
- # 1 "CONNECTx....x" #
- # 0 None of the above #
- # #
- ##############################################################################
- :CheckModem
- ######## Error conditions, 1 ########
- SetN modem 2
- CompA "%lastline%" with "SYSTEM SUSPENDED"
- IfEqu Goto CheckModemRet
- CompA "%lastline%" with "ERROR"
- IfEqu Goto CheckModemRet
- CompA "%lastline%" with "NODIALTONE"
- IfEqu Goto CheckModemRet
- CompA "%lastline%" with "NO DIALTONE"
- IfEqu Goto CheckModemRet
- CompA "%lastline%" with "NOANSWER"
- IfEqu Goto CheckModemRet
- CompA "%lastline%" with "NO ANSWER"
- IfEqu Goto CheckModemRet
- CompA "%lastline%" with "BUSY"
- IfEqu Goto CheckModemRet
- CompA "%lastline%" with "HANGUP"
- IfEqu Goto CheckModemRet
- CompA "%lastline%" with "HANG UP"
- IfEqu Goto CheckModemRet
- CompA "%lastline%" with "+++"
- IfIn Goto CheckModemRet
- CompA "%lastline%" with "NO CARRIER"
- IfEqu Goto CheckModemRet
- ######## "CONNECT", 1 ########
- SetN modem 1
- SetA worka "%lastline%" +1 7
- CompA "%worka%" with "CONNECT"
- IfEqu Goto CheckModemRet
- ######## None of the above, 0 ########
- SetN modem 0
- :CheckModemRet
- return
-
- ##############################################################################
- # CheckResult #
- # Num Variable result is set to the following values according to the #
- # contents of the system variable lastline: #
- # #
- # 9 none of the following #
- # 8 ##xx...x## and none of the following #
- # 7-3 unused #
- # 2 ##ERROR## #
- # 1 ##CANCEL## #
- # 0 ##OK## #
- # #
- ##############################################################################
- :CheckResult
- ######## ##OK##, 0 ########
- SetN result 0
- CompA "%lastline%" with "##OK##"
- IfEqu Goto CheckResultRet
- ######## ##ERROR##, 2 ########
- SetN result 2
- CompA "%lastline%" with ##ERROR##
- IfEqu Goto CheckResultRet
- ######## ##CANCEL##, 1 ########
- SetN result 1
- CompA "%lastline%" with ##CANCEL##
- IfEqu Goto CheckResultRet
- ######## ##xx...x##, 8 ########
- SetN result 8
- IfEqu Goto CheckResultRet
- SetA worka "%lastline%" +1 2 ;## ##x....
- CompA "%worka%" with "##"
- IfEqu Goto CheckResultRet
- SetA worka "%lastline%" -1 2 ;## ....x##
- CompA "%worka%" with "##"
- IfEqu Goto CheckResultRet
- ######## None of the previous, 9 ########
- SetN result 9
- :CheckResultRet
- return
-
- ##############################################################################
- # SendToRemote #
- # Send filename to remote #
- # Check for errors. Result is in modem #
- # If no error detected, filecountok is incremented #
- # If error detected, filecountnok is incremented #
- ##############################################################################
- :SendToRemote
- Writeln "******* File '%filename%' being send to remote..."
- UpLoad z "%filename%"
- ########################################################################
- # Check Result. For some reason ##ERROR## is not an Error, sometimes. #
- ########################################################################
- call CheckResult
- Writeln "******* File '%filename%' sent to remote. Result: %lastline%, %result%"
-
- ########################################################################
- # The next 2 lines are for the bug (?) returning not ##OK## #
- # after upload failed once. Erase if bug(?) cleared #
- ########################################################################
- CompN %result% with 2 ;#erase line when bug cleared
- IfEqu SetN result 0 ;#erase line when bug cleared
-
- CompN %result% with 0
- IfnEqu Inc filecountnok
- IfEqu Inc filecountok
- CompN 0 with 0 ;#set EQUAL
- return
-
- ##############################################################################
- # Connect #
- # Send Choice #
- # if valid choice go to appropriate routine #
- # if exit or break condition leave routine #
- ##############################################################################
- :Connect
- ###########################################################################
- # Load Options for connected period #
- ###########################################################################
- LoadOpts "%HOSTCONN%"
- SetN connectmenu 1
- SetN connectend 0
- SetN msgreceived 0
- :ConnectLoop
- ########################################################################
- # Stay in this loop till error or exit #
- ########################################################################
- CompN %msgreceived% with 0
- IfEqu Send "^M^J[%CURDIR%] Enter Your Choice or ?:^M"
- CompN %connectmenu% with 0
- IfEqu Goto ConnectMenuEnd
- #####################################################################
- # Send Menu to remote. Only done on first pass or when calling Help #
- #####################################################################
- Send "╔═════════════════════════════ Your choice ═════════════════════════════╗^M"
- Send "║DIR, D = FileList of Host Dir │DIRD, DD * = DirList of Host Dir ║^M"
- Send "║CD, C * = Change Host Dir │ ║^M"
- Send "║>mmmmmmm = Message mmmm to Host │>>mmmmmmm = Bell & Message to Host║^M"
- Send "║UL = Upload to Host │DL = Download from Host ║^M"
- Send "║EXIT, X = Exit │HELP, ? = Help, this Info ║^M"
- Send "╚════════════════════ * only valid in extended mode ════════════════════╝^M"
- SetA connectmenu 0
- :ConnectMenuEnd
- CompN %msgreceived% with 0
- IfEqu Writeln "^M******* Waiting for order from remote..."
- SetA choice " "
- :ConnectLoopWait
- WaitLine
- IfBrk Goto ConnectLoopWait
- :ConnectLoopWaitEnd
- Call CheckModem ;#check for drop conditions
- CompN %modem% with 1
- IfHigh Goto ConnectLoopEnd ;#Error
- ########################################################################
- # Evaluate choice and perform function #
- ########################################################################
- SetN modem 0
- SetA choice "%lastline%"
- Lower choice
- Ltrim choice
- Rtrim choice
-
- ########## >, >> = Message to host ##########
- SetN msgreceived 1
- SetA choicemsg "%choice%" +1 1
- CompA "%choicemsg%" with ">"
- IfEqu Goto ConnectMsg
- SetN msgreceived 0
-
- Writeln "******* Order received from remote: '%choice%'"
-
- ########## Help, ? = Help ##########
- CompA "%choice%" with "?"
- IfEqu Goto ConnectHelp
- CompA "%choice%" with "help"
- IfEqu Goto ConnectHelp
-
- ########## Exit, X = Exit ##########
- CompA "%choice%" with "x"
- IfEqu Goto ConnectExit
- CompA "%choice%" with "exit"
- IfEqu Goto ConnectExit
-
- ########## DL = Download from Host ##########
- CompA "%choice%" with "dl"
- IfEqu Goto ConnectDL
-
- ########## UL = Upload to Host ##########
- CompA "%choice%" with "ul"
- IfEqu Goto ConnectUL
-
- ########## DIR, D = File-List of Host Dir ##########
- CompA "%choice%" with "d"
- IfEqu Goto ConnectDir
- CompA "%choice%" with "dir"
- IfEqu Goto ConnectDir
-
- ########## DIRD, DD = Dir-List of Host Dir ##########
- CompN %extendedfunc% with 0
- IfEqu Goto ConnectLoopDirDEnd
- CompA "%choice%" with "dd"
- IfEqu Goto ConnectDirD
- CompA "%choice%" with "dird"
- IfEqu Goto ConnectDirD
- :ConnectLoopDirDEnd
-
- ########## CD, C = Change Host Dir ##########
- CompN %extendedfunc% with 0
- IfEqu Goto ConnectLoopCdEnd
- CompA "%choice%" with "c"
- IfEqu Goto ConnectCD
- CompA "%choice%" with "cd"
- IfEqu Goto ConnectCD
- :ConnectLoopCdEnd
-
- ########## DEBUG0 & DEBUG1 ##########
- :ConnectDebug0
- CompA "%password%" with "KF_HOSTEXT"
- IfnEqu Goto ConnectDebugEnd
- CompA "%choice%" with "debug0"
- IfnEqu Goto ConnectDebug1
- debug 0
- Goto ConnectLoop
- :ConnectDebug1
- CompA "%choice%" with "debug1"
- IfnEqu Goto ConnectDebugEnd
- debug 1
- Goto ConnectLoop
- :ConnectDebugEnd
-
- ########## ConnectInvalid ##########
- :ConnectInvalid
- Send "^M %choice% is not a valid choice.^M"
- Goto ConnectLoop
-
- ########################################################################
- # Check completion #
- ########################################################################
- :ConnectCheck
- CompN %connectend% with 0
- IfEqu Goto ConnectLoop ;#dont't exit
- :ConnectCheckEnd
- :ConnectLoopEnd
- Goto ConnectEnd
-
- ###########################################################################
- # Perform function according to choice #
- ###########################################################################
- :ConnectHelp ;#Help
- SetN connectmenu 1
- Goto ConnectLoop
-
- :ConnectExit ;#Exit
- Send "^MThanks for calling. Bye! ^M^J"
- Delay 2
- SetN connectend 1
- Goto ConnectCheck
-
- :ConnectMsg ;#> Send message
- call Msg
- IfnEqu SetN connectend 1
- Goto ConnectCheck
-
- :ConnectDL ;#DownLoad
- call DownLoad
- IfnEqu SetN connectend 1
- Goto ConnectCheck
-
- :ConnectUL ;#UpLoad
- Call UpLoad
- IfnEqu SetN connectend 1
- Goto ConnectCheck
-
- :ConnectDir ;#Dir
- Call Dir
- IfnEqu SetN connectend 1
- Goto ConnectCheck
-
- :ConnectDirD ;#DirD
- Call DirD
- IfnEqu SetN connectend 1
- Goto ConnectCheck
-
- :ConnectCD ;#ChangeDir
- Call ChangeDir
- IfnEqu SetN connectend 1
- Goto ConnectCheck
-
- :ConnectEnd
- return
-
-
- ##############################################################################
- # Msg #
- ##############################################################################
- :Msg
- SetA choicemsg "%choice%" +2 1
- CompA "%choicemsg%" with ">"
- IfnEqu Goto MsgNoBell
- Writeln "******* Beep from remote"
- BEEP 3
- DELAY 1
- BEEP 2
- DELAY 1
- BEEP 3
- :MsgNoBell
- CompN 0 with 0 ;#set EQAUL
- return
-
- ##############################################################################
- # Dir #
- ##############################################################################
- :Dir
- Shell "dir %CURDIR%>%TEMPFILE%"
- Send "^J"
- UpLoad a "%TEMPFILE%" ;#Upload ASCII
- Shell "del %TEMPFILE%" ;#Delete temp file
- CompN 0 with 0 ;#set EQUAL
- return
-
- ##############################################################################
- # DirD #
- ##############################################################################
- :DirD
- Shell "dir /ad %CURDIR%>%TEMPFILE%"
- Send "^M"
- UpLoad a "%TEMPFILE%" ;#Upload ASCII
- Shell "del %TEMPFILE%" ;#Delete temp file
- CompN 0 with 0 ;#set EQUAL
- return
-
- ##############################################################################
- # ChangeDir #
- ##############################################################################
- :ChangeDir
- Send "^MEnter directory (blank cancels): "
- :ChangeDirLoop
- ########################################################################
- # Get name of directory from remote #
- ########################################################################
- WaitLine
- IfBrk Goto ChangeDirLoop
- :ChangeDirLoopEnd
- Call CheckModem ;#check for drop conditions
- CompN %modem% with 1
- IfHigh Goto ChangeDirExit ;#drop condition
- ###########################################################################
- # Test wether directory exits #
- ###########################################################################
- SetA filename "%lastline%"
- CompA "%filename%" with " "
- IfEqu Goto ChangeDirRet
- Ltrim filename
- Rtrim filename
- Lower filename
- Call CheckDirPresent ;#filename is "" if dir not present
- CompA "%filename%" with "%filenamesave%"
- IfEqu Goto ChangeDirOk
- Send "^M Directory %filenamesave% does not exist.^M"
- Goto ChangeDirRet
- :ChangeDirOk
- SetA CURDIR "%filename%"
- :ChangeDirRet
- CompN 0 with 0 ;#set EQUAL condition
- :ChangeDirExit
- return
-
- ##############################################################################
- # DownLoad (from remote's point of view) #
- ##############################################################################
- :DownLoad
- SetN filecountok 0
- SetN filecountnok 0
- Send "^M^J^JEnter space to Cancel -or- Filename, wild cards are welcome: "
- :DownLoadNameLoop
- ########################################################################
- # Get name of file(s) from remote #
- ########################################################################
- Waitline
- IfBrk Goto DownLoadNameLoop
- :DownLoadNameLoopEnd
- Call CheckModem ;#check for drop, set result to modem
- CompN %modem% with 1
- IfHigh Goto DownloadEnd ;#drop condition
- :DownLoadNameLoopEnd
-
- ###########################################################################
- # Writeln file spec. Check for Cancel, first char is " " #
- ###########################################################################
- SetA filename "%lastline%"
- Writeln "File spec: '%CURDIR%%filename%'"
- SetA blank "%filename%" +1 1
- CompA "%blank%" with " "
- IfEqu Goto DownLoadExit
- ###########################################################################
- # Get single file or create filelist of all files if there are wildcards #
- ###########################################################################
- CompA "%filename%" with "*"
- IfIn Goto DownLoadWild
- CompA "%filename%" with "?"
- IfIn Goto DownLoadWild
- ########################################################################
- # No wild cards. test wether file exists #
- ########################################################################
- SetA filename "%CURDIR%%filename%"
- OpenFile "%filename%" "r"
- CompA "%lastline%", "##OK##"
- IfnEqu Goto DownLoadExit
- CloseFile
- Call SendToRemote
- Goto DownLoadExit
- :DownLoadNoWildEnd
-
- ###########################################################################
- # Create and Read List. Call upload (from here) for each file #
- ###########################################################################
- :DownLoadWild
- Shell "dir %CURDIR%%filename%>%TEMPFILE%"
- OpenFile "%TEMPFILE%" "r"
- Compa "%lastline%" with "##OK##"
- IfnEqu Goto DownLoadExit
- :DownLoadFileLoop
- GetFile
- Seta fileline "%lastline%"
- CompA "%fileline%" with "##" ;#Eof etc.
- IfIn Goto DownLoadFileLoopEnd
- Seta filename "%fileline%" +3 1
- CompA "%filename%" with "." ;#dot in 3rd position is candidate
- IfnEqu Goto DownLoadFileLoop
- CompA "%fileline%" with "<DIR>" ;#Directory
- IfIn Goto DownLoadFileLoop
- ########################################################################
- # Coming here must be a file name in 41th position. Do upload #
- ########################################################################
- Seta filename "%fileline%" +41
- Seta filename "%CURDIR%%filename%"
- Call SendToRemote
- Goto DownLoadFileLoop
- :DownLoadFileLoopEnd
- CloseFile
- shell "del %TEMPFILE%"
- :DownLoadExit
- Writeln "Files send to remote: Ok=%filecountok%, NotOk=%filecountnok%"
- Send "Files from host: Ok=%filecountok%, NotOk=%filecountnok%"
- :DownloadEnd0
- CompN 0 with 0 ;#set EQUAL condition
- :DownloadEnd
- return
-
- ##############################################################################
- # UpLoad (from remote's point of view) #
- ##############################################################################
- :UpLoad
- Send "^MStart your Zmodem upload.^M"
- Send "To cancel hit Cancel in your Upload-Box and press Ctrl/X several times."
- :UpLoadLoop
- download z "dummy"
- call CheckResult ;#check for drop
- Writeln "Download completed. Result: %lastline%, %result%"
- :UpLoadRet
- CompN 0 with 0 ;#set EQUAL
- return
-
- ##############################################################################
- # CheckPassWord #
- # Check password. If Ok return with 'passwordok' set to 1 (else 0). #
- # If Password does allow extended functions set 'extendedfunc' to 1 (else 0).#
- # #
- # Password are held in file name held in file scripvariable PASSWORDFILE. #
- # Format of passwords #
- # epassword #
- # ┬ ───┬─── #
- # │ └────── Password #
- # └─────────── 1 if Password authorizes for extended functions (else 0) #
- # #
- ##############################################################################
- :CheckPassWord
- SetN extendedfunc 0
- SetN passwordok 0
- SetA passw "%lastline%"
- Rtrim passw
- OpenFile "%PASSWORDFILE%" "r"
- CompA "%lastline%" with ##OK##
- IfnEqu Goto CheckPassWordEnd
- :CheckPassWordLoop
- GetFile
- SetA filepassw "%lastline%"
- CompA "%filepassw%" with "##"
- IfIn Goto CheckPassWordLoopEnd
- SetA filepasse "%filepassw%" +1 1
- SetA filepassw "%filepassw%" +3
- CompA "%filepassw%" with "%passw%"
- IfnEqu Goto CheckPassWordLoop
- SetN passwordok 1
- CompA %filepasse% with 1
- IfEqu SetN extendedfunc 1
- :CheckPassWordLoopEnd
- CloseFile
- :CheckPassWordEnd
- return
-
- ##############################################################################
- # Desaster exit #
- ##############################################################################
- :Desaster
- Writeln "******** Catastrophic Error. Script terminated. Rc=>%desaster%< ********"
- exit
-